/**
 * App module.
 * 2016/04/15
 */
define([
		'jquery',
		'pageInit',
		'select2'
	], function($, vamakerPage, select2) {
	// Brand Switch
	$(function () {
		var $brandNameSwitch = $('#brand-name-switch'),
			brandSwitchUrl = VAM.getVar('BRAND_SWITCH_URL'),
		brandSwitchCallback;
		brandSwitchCallback = function (name) {
			$.ajax({
				url: brandSwitchUrl,
				type: 'GET',
				data: {
					name: name,
					rnd: (new Date()).getTime()
				},
				beforeSend: function () {
				}
			})
			.done(function (data) {
				window.location.reload();
			})
			.fail(function () {
				console.log('Switch Error!');
			}).always(function () {
			});
		};
		$brandNameSwitch.select2();
		$brandNameSwitch.on('change', function (evt) {
			var $me = $(this),
				name = $me.val()
			brandSwitchCallback(name);
		});
	});
});